class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        int n = score.size();
        vector<string> ret(n);
        priority_queue<pair<int, int>> heap;
        for (int i = 0; i < n; i++) heap.push({ score[i], i });
        int j = 1;
        while (!heap.empty())
        {
            if (j == 1) {
                ret[heap.top().second] = "Gold Medal";
            }
            else if (j == 2) {
                ret[heap.top().second] = "Silver Medal";
            }
            else if (j == 3) {
                ret[heap.top().second] = "Bronze Medal";
            }
            else {
                ret[heap.top().second] = to_string(j);
            }
            j++;
            heap.pop();
        }
        return ret;
    }
};

class Solution {
public:
    string removeKdigits(string num, int k) {
        string ret = "";
        int remain = num.size() - k;
        if (remain <= 0) return "0";
        for (auto& c : num)
        {
            while (k != 0 && ret.size() >= 1 && ret.back() > c)
            {
                ret.pop_back();
                k--;
            }
            ret.push_back(c);
        }
        ret = ret.substr(0, remain);
        while (*ret.begin() == '0' && ret.size() > 1)
            ret.erase(ret.begin());
        return  ret;
    }
};